use crate::collections::chain::ChainBase;

pub trait QueueBase<T> {
    fn new() -> Self;
    fn push(&mut self, val: T);
    fn pop(&mut self) -> Option<T>;
    fn size(&self) -> u64;
}

pub struct Queue<C>(C);

impl<T, C: ChainBase<T>> QueueBase<T> for Queue<C> {
    #[inline]
    fn new() -> Self {
        Queue(C::new())
    }

    #[inline]
    fn push(&mut self, val: T) {
        self.0.push(val)
    }

    #[inline]
    fn pop(&mut self) -> Option<T> {
        self.0.pop_head()
    }

    #[inline]
    fn size(&self) -> u64 {
        self.0.size()
    }
}
